package org.liveboardgames.agricola.control.delegates.action.overrideaction
{
	import org.liveboardgames.agricola.control.delegates.helper.GameHelper;
	import org.liveboardgames.agricola.model.enums.ResourceTypeEnum;
	import org.liveboardgames.agricola.vo.action.Action;
	import org.liveboardgames.agricola.vo.common.Target;
	import org.liveboardgames.agricola.vo.farm.Farm;
	import org.liveboardgames.agricola.vo.player.Player;
	import org.liveboardgames.common.dictionary.collections.IMap;


	public class RenovationToStoneActionOverride extends ActionOverride
	{

		public function RenovationToStoneActionOverride(overriddenAction:Action, target:Target)
		{
			super(overriddenAction, target);
		}

		public override function overrideAction():void
		{
			trace("Overriding action " + overriddenAction);
			// Simply set the cost of the action (for now)
			if (target is Player)
			{
				var player:Player = target as Player;
				var farm:Farm = player.farm;

				// Get the number of rooms of the player's house
				var numberOfRooms:int = GameHelper.getNumberOfRooms(farm);

				// Cost is one stone per room and one reed
				var cost:IMap = overriddenAction.cost;
				cost.put(ResourceTypeEnum.REED, 1);
				cost.put(ResourceTypeEnum.STONE, numberOfRooms);
			}

		}

	}
}